﻿using System;

namespace H.Daos.Attributes
{
    /// <summary>
    /// 表示一个数据库的列
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class ColumnAttribute : Attribute
    {
        /// <summary>
        /// 列名
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// 列数据类型
        /// </summary>
        public DbType Type { get; set; } = DbType.NULL;

        /// <summary>
        /// 当前列是否为主键
        /// </summary>
        public bool PrimaryKey = false;

        /// <summary>
        /// 是否为自动递增列
        /// </summary>
        public bool AutoIncrement = false;

        /// <summary>
        /// 列不能为空
        /// </summary>
        public bool NotNull = false;

        /// <summary>
        /// 是否为唯一值列
        /// </summary>
        public bool Unique = false;

        /// <summary>
        /// 当前列默认值
        /// </summary>
        public string DefaultValue = "";



        /// <summary>
        /// 初始化一个数据库的列
        /// </summary>
        /// <param name="columnName"></param>
        public ColumnAttribute(string columnName)
        {
            Name = columnName;
        }


    }
}
